/*
** 2719.c
** 
** Made by (seakage2h)
** Login   <seakage2h@seakage2h-ubuntu>
** 
** Started on  Sun Sep 21 20:23:56 2008 seakage2h
** Last update Sun May 12 01:17:25 2002 Speed Blue
*/

/* #include "2719.h" */
#include <stdio.h>
#include <string.h>

int main()
{
     int power_9[10];
     char odometer[10];
     int conv_num;
     int digits;
     int i;

     /* INITIALIZE the powers of 9 */
     for(i = 2, power_9[1] = 1; i < 10; i++)
	  power_9[i] = power_9[i - 1] * 9;
	  
     while(scanf("%s", odometer)){
	  conv_num = 0;
	  if (odometer[0] == '0') break;
	  digits = strlen(odometer);
	  for(i = 0; i < digits; i++){
	       if (odometer[i] > '4')
		    conv_num += (odometer[i] - 1 - '0') * power_9[digits - i];
	       else
		    conv_num += (odometer[i] - '0') * power_9[digits - i];    
	  }
	  printf("%s: %d\n", odometer, conv_num);
     }
     
     return 0;
}
